package org.therandoms.textgen;

import jm.music.data.Note;
import jm.music.data.Part;
import jm.music.data.Phrase;
import jm.music.data.Score;


/**
 * Generates a random musical composition based on an incoming string of text. 
 * @author logan
 *
 */
public class MusicGenerator {
	/**
	 * Makes a musical score from the bytes of an object's string representation.
	 * @param obj the object
	 * @return the score. 
	 */
	public static<T> Score makeScoreFromBytes(T obj){
		byte bytes[] = obj.toString().getBytes();
		Score retScore = new Score();
		Part mPart = new Part();
		Phrase mPhrase = new Phrase();
		retScore.add(mPart);
		mPart.add(mPhrase);
		
		//make the notes
		for(byte b : bytes){
			mPhrase.add(new Note(b % 127, Note.DEFAULT_RHYTHM_VALUE));
		}
		
		return retScore;
	}
	
	
}
